/**
 * Created by Administrator on 2017-06-14.
 */
var convoyRunning = {
    init : function(){
    	this.curQueryStartTime="";
    	this.curQueryEndTime="";
        this.behavior=this.chartDriving();
        this.mileage=this.chartMillage();
        this.initVehicleList();
        this.bind();
        this.doSelTime();
        this.loadDetailsTitle();
        this.bindExportExcel();
    },

    chartMillage : function(){
        var option = {

            tooltip : {
                trigger: 'axis',
                formatter: function (params) {
		            params = params[0];
		            return "日期:"+params.name+"<br/>"+"里程:"+params.value;
		        },
		        axisPointer: {
		        	animation: false
		        }
            },
            legend: {
                data:['行驶里程']
            },
            grid: {
                left: '20px',
                right: '33px',
                containLabel: true
            },
            xAxis : [
                {
                    type : 'category',
                    boundaryGap : false,
                    data : []
                }
            ],
            yAxis : [
                {
                    type : 'value'
                }
            ],
            series : [
                {
                    name:'行驶里程',
                    type:'line',
                    stack: '总里程',
                    data:[]
                }
            ],
		    dataZoom: [{
		        type: 'inside',
		        start: 0,
		        end: 100
		    }, {
		        start: 0,
		        end: 100,
		        fillerColor:'#A3E1A3',
		        handleColor:'#83A7D1'
		    }]
        };
        var myChart = echarts.init(document.getElementById('chartMillage'));
        myChart.setOption(option);
        window.onresize = myChart.resize;
        return {
        	refash : function(option){
                myChart.setOption(option);
        	},
        	option : option,
        	chartMillageDom : myChart
        };
    },

    chartDriving : function(){
    	
        var option = {
            tooltip : {
                trigger: 'axis'
            },
            legend: {
                data:[
                	'报警类型'
                	]
            },
            grid: {
                left: '3px',
                right: '33px',
                containLabel: true
            },
            calculable : true,
            xAxis : [
                {
                    type : 'category',
                    data : []
                }
            ],
            yAxis : [
                {
                    type : 'value'
                }
            ],
            series : [
                {
                	name:'报警类型',
                    type:'bar',
                    data:[]
                },
                /* {
                    name:'疲劳驾驶',
                    type:'bar',
                    data:[]
                },
                {
                    name:'进出区域',
                    type:'bar',
                    data:[]
                },
                {
                    name:'线路偏移',
                    type:'bar',
                    data:[]
                },
                {
                    name:'进出地点',
                    type:'bar',
                    data:[]
                }*/
              /*  ,
                {
                    name:'其它报警',
                    type:'bar',
                    data:[]
                }*/
            ],
		    dataZoom: [{
		        type: 'inside',
		        start: 0,
		        end: 100
		    }, {
		        start: 0,
		        end: 100,
		        fillerColor:'#A3E1A3',
		        handleColor:'#83A7D1'
		    }]
        };
        var myChart = echarts.init(document.getElementById('chartDriving'));
        myChart.setOption(option);
        window.onresize = myChart.resize;
      
        //myChart.setOption(option);
        
        return {
        	refash : function(option){
                myChart.setOption(option);
        	},
        	option : option,
        	chartDrivingDom : myChart
        };
        
    },
    initVehicleList:function(){
    	$.ajax({
    		type : 'post',
    		async : false,
    		url : appCtx + "/report/convoyRunning/loadVehicleUnit.html",
    		cache : false,
    		dataType : "JSON",
    		success : function(data) {			
    			if(data){
    				 var selectStr="<option value=''>请选择</option>";
    				for(var i=0;i<data.length;i++){
    					selectStr+="<option value='"+data[i].id+"'>"+data[i].name+"</option>";

    				}
    				
    				$('#selectVehicleUnitSel').html(selectStr);
    				
    				$("#selectVehicleUnitSel").select2();

    			}
    		}
    	});
    },
    queryConvoyRuning:function(){
      var _this = this;
      _this.curQueryStartTime=$("#inputStartDate").val()+" 00:00:00";
      _this.curQueryEndTime=$("#inputEndDate").val()+" 59:59:59";
      var startTime=$("#inputStartDate").val()+" 00:00:00";
   	  var endTime=$("#inputEndDate").val()+" 23:59:59";
   	  var workunitid=$("#selectVehicleUnitSel").val();
   	  
  	var end_str = (endTime).replace(/-/g,"/");//一般得到的时间的格式都是：yyyy-MM-dd hh24:mi:ss，所以我就用了这个做例子，是/的格式，就不用replace了。  
	var end_date = new Date(end_str);//将字符串转化为时间  
	//开始时间  
	var sta_str = (startTime).replace(/-/g,"/");  
	var sta_date = new Date(sta_str);  
	var num = (end_date-sta_date)/(1000*3600*24);//求出两个时间的时间差，这个是天数  
	var days = parseInt(Math.ceil(num));//转化为整天（小于零的话剧不用转了） 
	if(days>30){
		global.ajaxLoading.pop("查询时间不能超过30天",false,2000);
		return;
	}
	
	
   	  var url=appCtx+"report/convoyRunning/getConvoyRunning.html?startTime="+startTime+"&endTime="+endTime+"&workunitid="+workunitid;
   	 if(workunitid==null || workunitid==""){
   		 global.ajaxLoading.pop("请选择企业！",false,2000);
   		 return false;
   	 }
   	global.ajaxLoading.pop('正在拼命加载,请稍候!',true);
   	 $.post(url,function(data){
   		 var listConvoyRunning=data.listConvoyRunning;
   		 var listConvoyRunningDetails=data.listConvoyRunningDetails;
   		 dayObj=listConvoyRunningDetails;
   		 var objConvoyChars=data.listConvoyRunningConvoy;
   		 var objTableHtml="";
   		 $("#objTable").empty();
   		 
   		 objTableHtml+="<tr id='objTitle'><th>车队</th><th>总里程</th><th>行驶时长</th><th>图片</th><th>路段超速</th><th>夜间行车</th><th>车辆超速</th><th>疲劳驾驶</th></tr>"
   		 if(listConvoyRunning!=null&&listConvoyRunning.length>0){
   	   	  //var workunitid=$("#selectVehicleUnitSel").val();
   			 if(workunitid!=null&&workunitid!=""&&workunitid!="null"){
   				var obj=listConvoyRunning[0];		 
   				objTableHtml+="<tr id='objInfo'>";
   				objTableHtml+="<td>"+$("#selectVehicleUnitSel").find("option:selected").text()+"</td>"+"<td>"+(obj.totalMileage)+"km</td>"+"<td>"+_this.doTimeFormat(obj.duration)+"</td>";
   				objTableHtml+="<td>"+obj.picCount+"</td>"+"<td>"+obj.totalRoadOverspeed+"</td>"+"<td>"+obj.totalNightDriving+"</td>";
   				objTableHtml+="<td>"+obj.totalVehicleSpeed+"</td>"+"<td>"+obj.totalVehicleTired+"</td>";				
   				objTableHtml+="</tr>";
   			 }
   			
   			 
   			
   		 }
   				 
   		 var nightDrivingArr=[];
   		 var roadOverSpeedArr=[];
   		 var vehicleSpeedArr=[];
   		 var vehicleTiredArr=[];
   	     
   		 var titleArr=[];
   	   
   	     var dateArr=[];
   	     var mileageArr=[];
   	     
   	     var option = _this.behavior.option;
   	     var optionMileage=_this.mileage.option;
   	     
   	     var totalRoadOverspeed=0;
	     var totalNightDriving=0;
	     var totalVehicleSpeed=0;
	     var totalVehicleTired=0;
	     
   	     if(typeof(listConvoyRunningDetails)!="undefined"){
   	    	 
   	    	var dataRows= {
   	    			rows:listConvoyRunningDetails,
   	    			totol:listConvoyRunningDetails.length,
   	    			page:1
   	    			};
   	    	$("#ObjTableDetails").flexAddData(dataRows);
   	    	 
   	    	 for(var i=0;i<objConvoyChars.length;i++){
   	   			 var obj=objConvoyChars[i];
   	   			 
   	   			 roadOverSpeedArr.push(obj.totalRoadOverspeed);
	   			 nightDrivingArr.push(obj.totalNightDriving);
	   		     vehicleSpeedArr.push(obj.totalVehicleSpeed);
	   		     vehicleTiredArr.push(obj.totalVehicleTired);
   	   		    
   	   		     dateArr.push(obj.analyseDate);
   	   		     mileageArr.push(obj.totalMileage); 
   	   		     
   	   		     totalRoadOverspeed=totalRoadOverspeed+obj.totalRoadOverspeed;
	   		     totalNightDriving=totalNightDriving+obj.totalNightDriving;
	   		     totalVehicleSpeed=totalVehicleSpeed+obj.totalVehicleSpeed;
	   		     totalVehicleTired=totalVehicleTired+obj.totalVehicleTired;
   	   		 }
   	    	 
   	    	if(totalRoadOverspeed>=0){
  	    		 option.series[0]={
  	    				name:'道路超速' ,
  	    				type:'bar',
  	    		 		data:roadOverSpeedArr 	 
  	    		 };
 	    		 titleArr[0]='道路超速';
 	    	 }
  	    	 if(totalNightDriving>=0){
  	    		 option.series[1]={
  	    				name:'夜间行车' ,
  	    				type:'bar',
  	    		 		data:nightDrivingArr	 
  	    		 };
 	    		 titleArr[1]='夜间行车';
 	    	 }
  	    	 if(totalVehicleSpeed>=0){
  	    		 option.series[2]={
  	    				name:'超速' ,
  	    				type:'bar',
  	    		 		data:vehicleSpeedArr	 
  	    		 };
 	    		 titleArr[2]='超速';
 	    	 }
  	    	if(totalVehicleTired>=0){
  	    		option.series[3]={
  	    				name:'疲劳' ,
  	    				type:'bar',
  	    		 		data:vehicleTiredArr		
  	    		};
 	    		 titleArr[3]='疲劳';
 	    	 }
  	   		
  	   		
  		    
  		    
  	    	 option.legend[0]=titleArr;
   		     
   		     option.xAxis[0].data=dateArr;
   	   		_this.behavior.refash(option);
   	   		 
   	   		optionMileage.series[0].data=mileageArr;
   	   		optionMileage.xAxis[0].data=dateArr;
   	   		_this.mileage.refash(optionMileage); 
   	     }
   		
   		 
   		 
   		 $("#objTable").append(objTableHtml);
   		global.ajaxLoading.close();
   	 },"json");
    },
	getAreaInOutColumn:function(){
		return [{
            display : '车牌号码',
            name : 'registrationNo',
            width : 10,
            sortable : true,
            align : 'left'
        },{
            display : '自编号',
            name : 'internalNo',
            width : 10,
            sortable : true,
            align : 'left'
        },{
            display : '企业名称',
            name : 'workUnitName',
            width : 10,
            sortable : true,
            align : 'left'
        },{
            display : '进入时间',
            name : 'intodatetime',
            width : 10,
            sortable : true,
            align : 'left'
        },{
            display : '离开时间',
            name : 'outdatetime',
            width : 10,
            align : 'left',
            sortable:true
        },{
            display : '总时长',
            name : 'totaltime',
            width : 10,
            
            align : 'left',
            sortable:true,
            paramcolnames:['totaltime'],
            handlefunction:convoyRunning.doTimeFormat
        },{
            display : '进入的经度',
            name : 'intolon',
            width : 10,
            
            align : 'left',
            sortable:true,
            paramcolnames:['intolon'],
            handlefunction:convoyRunning.doLatLngFormat
        },{
            display : '进入的纬度',
            name : 'intolat',
            width : 15,
            
            align : 'left',
            sortable:true,
            paramcolnames:['intolat'],
            handlefunction:convoyRunning.doLatLngFormat
        },{
            display : '进入的位置',
            name : 'inotposition',
            width : 10,
            
            align : 'left',
            sortable:true
          
        },{
            display : '离开的经度',
            name : 'outlon',
            width : 15,
            
            align : 'left',
            sortable:true,
            paramcolnames:['outlon'],
            handlefunction:convoyRunning.doLatLngFormat
           
        },{
            display : '离开的纬度',
            name : 'outlat',
            width : 10,
            
            align : 'left',
            sortable:true,
            paramcolnames:['outlat'],
            handlefunction:convoyRunning.doLatLngFormat
           
        },{
            display : '离开的位置',
            name : 'outposition',
            width : 10,
            
            align : 'left',
            sortable:true
            
            
        },{
            display : '区域名称',
            name : 'coveragename',
            width : 10,
            
            align : 'left',
            sortable:true
            
            
        },{
            display : '分析器名称',
            name : 'analyseconditions',
            width : 10,
            
            align : 'left',
            sortable:true
            
            
        },{
            display : '创建时间',
            name : 'createdatetime',
            width : 10,
            
            align : 'left',
            sortable:true
            
            
        },{
            display : '进入里程',
            name : 'intomileage',
            width : 10,
            
            align : 'left',
            sortable:true,
            paramcolnames:['intomileage'],
            handlefunction:convoyRunning.doMileageFormat
            
            
        },{
            display : '离开里程',
            name : 'outmileage',
            width : 10,
            
            align : 'left',
            sortable:true,
            paramcolnames:['outmileage'],
            handlefunction:convoyRunning.doMileageFormat
            
            
        }]
	},
	getRadInoutColumn:function(){
		return [{
            display : '车牌号码',
            name : 'registrationNo',
            width : 10,
            
            align : 'left'
        },{
            display : '自编号',
            name : 'internalNo',
            width : 10,
            
            align : 'left'
        },{
            display : '企业名称',
            name : 'workUnitName',
            width : 10,
            
            align : 'left'
        },{
            display : '车辆颜色',
            name : 'platecolor',
            width : 10,
            
            align : 'left'
        },{
            display : '车队名称',
            name : 'motorcadename',
            width : 10,
            
            align : 'left',
            sortable:true
        },{
            display : '司机的身份证',
            name : 'drivericcode',
            width : 10,
            
            align : 'left',
            sortable:true
        },{
            display : '司机的名称',
            name : 'drivername',
            width : 10,
            
            align : 'left',
            sortable:true
        },{
            display : '司机的电话',
            name : 'driverphone',
            width : 15,
            
            align : 'left',
            sortable:true
           
        },{
            display : '进入的时间',
            name : 'intodatetime',
            width : 10,
            
            align : 'left',
            sortable:true
          
        },{
            display : '离开的时间',
            name : 'outdatetime',
            width : 15,
            
            align : 'left',
            sortable:true
           
        },{
            display : '运行时长',
            name : 'totaltime',
            width : 10,
            
            align : 'left',
            sortable:true,
            paramcolnames:['totaltime'],
            handlefunction:convoyRunning.doTimeFormat
           
        },{
            display : '进入的经度',
            name : 'intolon',
            width : 10,
            
            align : 'left',
            sortable:true,
            paramcolnames:['intolon'],
            handlefunction:convoyRunning.doLatLngFormat
            
            
        },{
            display : '进入的纬度',
            name : 'intolat',
            width : 10,
            
            align : 'left',
            sortable:true,
            paramcolnames:['intolat'],
            handlefunction:convoyRunning.doLatLngFormat
            
        },{
            display : '进入的位置',
            name : 'inotposition',
            width : 10,
            
            align : 'left',
            sortable:true
            
            
        },{
            display : '离开的经度',
            name : 'outlon',
            width : 10,
            
            align : 'left',
            sortable:true,
            paramcolnames:['outlon'],
            handlefunction:convoyRunning.doLatLngFormat
            
        },{
            display : '离开的纬度',
            name : 'outlat',
            width : 10,
            
            align : 'left',
            sortable:true,
            paramcolnames:['outlat'],
            handlefunction:convoyRunning.doLatLngFormat
            
            
        },{
            display : '离开的位置',
            name : 'outposition',
            width : 10,
            
            align : 'left',
            sortable:true
            
        },{
            display : '偏移条件名称',
            name : 'coveragename',
            width : 10,
            
            align : 'left',
            sortable:true
            
            
        },{
            display : '进入里程',
            name : 'intomileage',
            width : 10,
            
            align : 'left',
            sortable:true,
            paramcolnames:['intomileage'],
            handlefunction:convoyRunning.doMileageFormat
            
            
        },{
            display : '进入的油耗',
            name : 'intooil',
            width : 10,
            
            align : 'left',
            sortable:true
            
            
        },{
            display : '出去的油耗',
            name : 'outoil',
            width : 10,
            
            align : 'left',
            sortable:true
            
            
        },{
            display : '分析条件名称',
            name : 'analyseconditions',
            width : 10,
            
            align : 'left',
            sortable:true
            
            
        },{
            display : '创建时间',
            name : 'createdatetime',
            width : 10,
            
            align : 'left',
            sortable:true
            
            
        },{
            display : '最大的偏移距离',
            name : 'maxoffsetdistance',
            width : 10,
            
            align : 'left',
            sortable:true,
            paramcolnames:['maxoffsetdistance'],
            handlefunction:convoyRunning.doMileageFormat
            
            
        }]
	},
	getLocaleInoutColumn:function(){
		return [{
            display : '车牌号码',
            name : 'registrationNo',
            width : 10,
            
            align : 'left'
        },{
            display : '自编号',
            name : 'internalNo',
            width : 10,
            
            align : 'left'
        },{
            display : '企业名称',
            name : 'workUnitName',
            width : 10,
            
            align : 'left'
        },{
            display : '进入的日期',
            name : 'intodatetime',
            width : 10,
            
            align : 'left'
        },{
            display : '出去的日期',
            name : 'outdatetime',
            width : 10,
            
            align : 'left',
            sortable:true
        },{
            display : '运行时长',
            name : 'totaltime',
            width : 10,
            
            align : 'left',
            sortable:true,
            paramcolnames:['totaltime'],
            handlefunction:convoyRunning.doTimeFormat
        },{
            display : '出去的经度',
            name : 'intolon',
            width : 10,
            
            align : 'left',
            sortable:true,
            paramcolnames:['intolon'],
            handlefunction:convoyRunning.doLatLngFormat
        },{
            display : '进去的纬度',
            name : 'intolat',
            width : 15,
            
            align : 'left',
            sortable:true,
            paramcolnames:['intolat'],
            handlefunction:convoyRunning.doLatLngFormat
           
        },{
            display : '出去的经度',
            name : 'outlon',
            width : 10,
            
            align : 'left',
            sortable:true,
            paramcolnames:['outlat'],
            handlefunction:convoyRunning.doLatLngFormat
          
        },{
            display : '出去的纬度',
            name : 'outlat',
            width : 15,
            
            align : 'left',
            sortable:true,
            paramcolnames:['outlat'],
            handlefunction:convoyRunning.doLatLngFormat
           
        },{
            display : '地点名称',
            name : 'coveragename',
            width : 10,
            
            align : 'left',
            sortable:true
           
        },{
            display : '分析条件名称',
            name : 'analyseconditions',
            width : 10,
            
            align : 'left',
            sortable:true
            
            
        },{
            display : '创建时间',
            name : 'createdatetime',
            width : 10,
            
            align : 'left',
            sortable:true
            
            
        },{
            display : '进去的里程',
            name : 'intomileage',
            width : 10,
            
            align : 'left',
            sortable:true,
            paramcolnames:['intomileage'],
            handlefunction:convoyRunning.doMileageFormat
            
            
        },{
            display : '出去的里程',
            name : 'outmileage',
            width : 10,
            
            align : 'left',
            sortable:true,
            paramcolnames:['outmileage'],
            handlefunction:convoyRunning.doMileageFormat
            
            
        }]
	},
	getVehicleSpeedColumn:function(){
		return [{
            display : '车牌号码',
            name : 'registrationNo',
            width : 100,
            
            align : 'left',
            showTitle : 'registrationNo'
        },{
            display : '自编号',
            name : 'internalNo',
            width : 100,
            
            align : 'left'
        },{
            display : '企业名称',
            name : 'workUnitName',
            width : 150,
            
            align : 'left',
            showTitle : 'workUnitName'
        },{
            display : '开始时间',
            name : 'startdatetime',
            width : 120,
            
            align : 'left'
        },{
            display : '结束时间',
            name : 'enddatetime',
            width : 120,
            
            align : 'left',
            sortable:true
        },{
            display : '超速时长',
            name : 'totaltime',
            width : 100,
            
            align : 'left',
            sortable:true,
            paramcolnames:['totaltime'],
            handlefunction:convoyRunning.doTimeFormat
        },{
            display : '最大速度',
            name : 'maxspeed',
            width : 60,
            
            align : 'left',
            sortable:true
        },{
            display : '最低速度',
            name : 'minspeed',
            width : 60,
            
            align : 'left',
            sortable:true
           
        },{
            display : '平均速度',
            name : 'averagespeed',
            width : 60,
            
            align : 'left',
            sortable:true
          
        },{
            display : '超速门限',
            name : 'speedthreshold',
            width : 60,
            
            align : 'left',
            sortable:true
           
        },{
            display : '超速类型',
            name : 'speedtype',
            width : 100,
            
            align : 'left',
            sortable:true
           
        },/*{
            display : '开始经度',
            name : 'startlon',
            width : 100,
            
            align : 'left',
            sortable:true,
            paramcolnames:['startlon'],
            handlefunction:convoyRunning.doLatLngFormat
            
            
        },{
            display : '开始纬度',
            name : 'startlat',
            width : 100,
            
            align : 'left',
            sortable:true,
            paramcolnames:['startlat'],
            handlefunction:convoyRunning.doLatLngFormat
            
            
        },*/{
            display : '开始位置',
            name : 'startposition',
            width : 100,
            
            align : 'left',
            sortable:true,
            paramcolnames:['startlon','startlat','startdatetime'],
            handlefunction:convoyRunning.getAddressS
            
            
        }/*,{
            display : '结束经度',
            name : 'endlon',
            width : 100,
            
            align : 'left',
            sortable:true,
            paramcolnames:['endlon'],
            handlefunction:convoyRunning.doLatLngFormat
            
            
        },{
            display : '结束纬度',
            name : 'endlat',
            width : 100,
            
            align : 'left',
            sortable:true,
            paramcolnames:['endlat'],
            handlefunction:convoyRunning.doLatLngFormat
            
            
        }*/,{
            display : '结束位置',
            name : 'endposition',
            width : 100,
            
            align : 'left',
            sortable:true,
            paramcolnames:['endlon','endlat','startdatetime'],
            handlefunction:convoyRunning.getAddressE
            
            
        },{
            display : '分析条件名称',
            name : 'analyseconditions',
            width : 100,
            
            align : 'left',
            sortable:true
            
            
        },{
            display : '总里程',
            name : 'totalmileage',
            width : 100,
            
            align : 'left',
            sortable:true,
            paramcolnames:['totalmileage'],
            handlefunction:convoyRunning.doMileageFormat
            
            
        }/*,{
            display : '创建时间',
            name : 'createdatetime',
            width : 120,
            
            align : 'left',
            sortable:true
            
            
        }*/]
	},
	getVehicleTiredColumn:function(){
		return [{
            display : '车牌号码',
            name : 'registrationNo',
            width : 100,
            
            align : 'left',
            showTitle : 'registrationNo'
        },{
            display : '自编号',
            name : 'internalNo',
            width : 100,
            
            align : 'left'
        },{
            display : '企业名称',
            name : 'workUnitName',
            width : 150,
            
            align : 'left',
            showTitle : 'workUnitName'
        },{
            display : '开始时间',
            name : 'startdatetime',
            width : 120,
            
            align : 'left'
        },{
            display : '开始疲劳时间',
            name : 'starttiredtime',
            width : 120,
            
            align : 'left',
            sortable:true
            
            
            
        },{
            display : '结束时间',
            name : 'enddatetime',
            width : 120,
            
            align : 'left',
            sortable:true
        },{
            display : '疲劳值',
            name : 'timethreshold',
            width : 100,
            
            align : 'left',
            sortable:true,
            paramcolnames:['timethreshold'],
            handlefunction:convoyRunning.doTimeFormatMin
        },{
            display : '疲劳驾驶时长',
            name : 'totaltime',
            width : 100,
            
            align : 'left',
            sortable:true,
            paramcolnames:['totaltime'],
            handlefunction:convoyRunning.doTimeFormatTire
            
        },/*{
            display : '开始经度',
            name : 'startlon',
            width : 100,
            
            align : 'left',
            sortable:true,
            paramcolnames:['startlon'],
            handlefunction:convoyRunning.doLatLngFormat
           
        },{
            display : '开始纬度',
            name : 'startlat',
            width : 100,
            
            align : 'left',
            sortable:true,
            paramcolnames:['startlat'],
            handlefunction:convoyRunning.doLatLngFormat

          
        },*/{
            display : '开始位置',
            name : 'startposition',
            width : 100,
            
            align : 'left',
            sortable:true,
            paramcolnames:['startlon','startlat','startdatetime'],
            handlefunction:convoyRunning.getAddressS
           
        }/*,{
            display : '结束经度',
            name : 'endlon',
            width : 100,
            
            align : 'left',
            sortable:true,
            paramcolnames:['endlon'],
            handlefunction:convoyRunning.doLatLngFormat
           
        },{
            display : '结束纬度',
            name : 'endlat',
            width : 109,
            
            align : 'left',
            sortable:true,
            paramcolnames:['endlat'],
            handlefunction:convoyRunning.doLatLngFormat
            
            
        }*/,{
            display : '结束位置',
            name : 'endposition',
            width : 100,
            
            align : 'left',
            sortable:true,
            paramcolnames:['endlon','endlat','startdatetime'],
            handlefunction:convoyRunning.getAddressE
            
            
        },{
            display : '开始里程',
            name : 'startmileage',
            width : 100,
            
            align : 'left',
            sortable:true,
            paramcolnames:['startmileage'],
            handlefunction:convoyRunning.doMileageFormat
            
            
        },{
            display : '结束里程',
            name : 'endmileage',
            width : 100,
            
            align : 'left',
            sortable:true,
            paramcolnames:['endmileage'],
            handlefunction:convoyRunning.doMileageFormat
            
            
        },{
            display : '总里程',
            name : 'totalmileage',
            width : 100,
            
            align : 'left',
            sortable:true,
            paramcolnames:['totalmileage'],
            handlefunction:convoyRunning.doMileageFormat
            
            
        },{
            display : '分析条件名称',
            name : 'analyseconditions',
            width : 100,
            
            align : 'left',
            sortable:true
            
            
        }/*,{
            display : '创建时间',
            name : 'createdatetime',
            width : 120,
            
            align : 'left',
            sortable:true
            
            
        }*/]
	},
	getRoadOverspeedColumn:function(){
		return [{ 
			display : '车牌号码',
            name : 'registrationNo',
            width : 100,
            sortable:true,
            align : 'left',
            showTitle : 'registrationNo'
        },{
            display : '自编号',
            name : 'internalNo',
            width : 100,
            sortable:true,
            align : 'left'
        },{
            display : '企业名称',
            name : 'workUnitName',
            width : 150,
            sortable:true,
            align : 'left',
            showTitle : 'workUnitName'
        },{
            display : '道路类型名称',
            name : 'roadLevelName',
            width : 100,
            sortable:true,
            align : 'left'
        },{
            display : '超速时长',
            name : 'totaltime',
            width : 100,
            sortable:true,
            align : 'left',
            paramcolnames:['totaltime'],
            handlefunction:convoyRunning.doTimeFormat
        },{
            display : '限速',
            name : 'limitspeed',
            width : 100,
            sortable:true,
            align : 'left'
        },{
            display : '最高速度',
            name : 'maxspeed',
            width : 100,
            sortable:true,
            align : 'left'
        },{
            display : '最低速度',
            name : 'minspeed',
            width : 100,
            sortable:true,
            align : 'left'
        },{
            display : '平均速度',
            name : 'avgspeed',
            width : 100,
            sortable:true,
            align : 'left'
        },{
            display : '开始时间',
            name : 'startdatetime',
            width : 120,
            sortable:true,
            align : 'left'
        },{
            display : '结束时间',
            name : 'enddatetime',
            width : 120,
            align : 'left',
            sortable:true
        },{
            display : '超速里程',
            name : 'over_speed_mileage',
            width : 100,
            align : 'left',
            sortable:true
        }/*,{
            display : '开始经度',
            name : 'startlon',
            width : 100,
            align : 'left',
            sortable:true,
            paramcolnames:['startlon'],
            handlefunction:convoyRunning.doLatLngFormat
        },{
            display : '开始纬度',
            name : 'startlat',
            width : 100,
            align : 'left',
            sortable:true,
            paramcolnames:['startlat'],
            handlefunction:convoyRunning.doLatLngFormat	
        },{
            display : '结束经度',
            name : 'endlon',
            width : 100,
            align : 'left',
            sortable:true,
            paramcolnames:['endlon'],
            handlefunction:convoyRunning.doLatLngFormat
        },{
            display : '结束纬度',
            name : 'endlat',
            width : 100,
            align : 'left',
            sortable:true,
            paramcolnames:['endlat'],
            handlefunction:convoyRunning.doLatLngFormat	
        }*/,{
            display : '开始位置',
            name : 'startposition',
            width : 100,
            sortable:true,
            align : 'left',
            paramcolnames:['startlon','startlat','startdatetime'],
            handlefunction:convoyRunning.getAddressS
        },{
            display : '结束位置',
            name : 'endposition',
            width : 100,
            sortable:true,
            align : 'left',
            paramcolnames:['endlon','endlat','startdatetime'],
            handlefunction:convoyRunning.getAddressE
        }]
        
	},
	getVehiclePicColumn:function(){
		return [{
            display : '车牌号码',
            name : 'registrationNo',
            width : 100,
            
            align : 'left',
            showTitle : 'registrationNo'
        },{
            display : '自编号',
            name : 'internalNumber',
            width : 100,
            
            align : 'left'
        },{
            display : '拍照时间',
            name : 'gpsTimeStr',
            width : 150,
            
            align : 'left'
        }/*,{
            display : '拍照经度',
            name : 'longitude',
            width : 100,
            
            align : 'left',
            sortable:true,
            paramcolnames:['longitude'],
            handlefunction:convoyRunning.doLatLngFormat
           
        },{
            display : '拍照纬度',
            name : 'latitude',
            width : 100,
            
            align : 'left',
            sortable:true,
            paramcolnames:['latitude'],
            handlefunction:convoyRunning.doLatLngFormat

          
        }*/,{
            display : '拍照位置',
            name : 'picPosition',
            width : 400,
            
            align : 'left',
            sortable:true,
            paramcolnames:['longitude','latitude','gpsTimeStr'],
            handlefunction:convoyRunning.getAddressS
           
        }]
	},
	getNightDrivingColumn:function(){
		 
	return [{ 
			display : '车牌号码',
            name : 'registrationNo',
            width : 100,
            sortable:true,
            align : 'left',
            showTitle : 'registrationNo'
        },{
            display : '自编号',
            name : 'internalNo',
            width : 100,
            sortable:true,
            align : 'left'
        },{
            display : '企业名称',
            name : 'workUnitName',
            width : 100,
            sortable:true,
            align : 'left',
            showTitle : 'workUnitName'
        },{
            display : '分析器名称',
            name : 'analyseconditions',
            width : 100,
            sortable:true,
            align : 'left'
        },{
            display : '开始时间',
            name : 'startdatetime',
            width : 120,
            sortable:true,
            align : 'left'
        },{
            display : '结束时间',
            name : 'enddatetime',
            width : 120,
            align : 'left',
            sortable:true
        },{
            display : '最小速度',
            name : 'minspeed',
            width : 100,
            sortable:true,
            align : 'left'
        },{
            display : '最大速度',
            name : 'maxspeed',
            width : 100,
            sortable:true,
            align : 'left'
        },{
            display : '平均速度',
            name : 'averagespeed',
            width : 100,
            sortable:true,
            align : 'left'
        },{
            display : '速度门限',
            name : 'speedthreshold',
            width : 100,
            align : 'left',
            sortable:true
        },/*{
            display : '开始经度',
            name : 'startlon',
            width : 100,
            align : 'left',
            sortable:true,
            paramcolnames:['startlon'],
            handlefunction:convoyRunning.doLatLngFormat
        },{
            display : '开始纬度',
            name : 'startlat',
            width : 100,
            align : 'left',
            sortable:true,
            paramcolnames:['startlat'],
            handlefunction:convoyRunning.doLatLngFormat	
        },{
            display : '结束经度',
            name : 'endlon',
            width : 100,
            align : 'left',
            sortable:true,
            paramcolnames:['endlon'],
            handlefunction:convoyRunning.doLatLngFormat
        },{
            display : '结束纬度',
            name : 'endlat',
            width : 100,
            align : 'left',
            sortable:true,
            paramcolnames:['endlat'],
            handlefunction:convoyRunning.doLatLngFormat	
        },*/{
            display : '开始位置',
            name : 'startposition',
            width : 100,
            sortable:true,
            align : 'left',
            paramcolnames:['startlon','startlat','startdatetime'],
            handlefunction:convoyRunning.getAddressS
        },{
            display : '结束位置',
            name : 'endposition',
            width : 100,
            sortable:true,
            align : 'left',
            paramcolnames:['endlon','endlat','startdatetime'],
            handlefunction:convoyRunning.getAddressE
        },{
            display : '开始里程',
            name : 'startmileage',
            width : 100,
            align : 'left',
			sortable:true,
            paramcolnames:['startmileage'],
            handlefunction:convoyRunning.doMileageFormat
        },{
            display : '结束里程',
            name : 'endmileage',
            width : 100,
            align : 'left',
			sortable:true,
            paramcolnames:['endmileage'],
            handlefunction:convoyRunning.doMileageFormat
        },{
            display : '总耗时',
            name : 'totaltime',
            width : 100,
            align : 'left',
			sortable:true,
            paramcolnames:['totaltime'],
            handlefunction:convoyRunning.doTimeFormat
        },{
        	display : '夜间行驶里程',
            name : 'totalmileage',
            width : 100,
            align : 'left',
			sortable:true,
            paramcolnames:['totalmileage'],
            handlefunction:convoyRunning.doMileageFormat
        }/*,{
            display : '创建时间',
            name : 'createdatetime',
            width : 120,
            sortable:true,
            align : 'left'
        }*/]
	},
    /**
     * 详情弹窗
     * */
    
    popNightDrivingModel : function(alarmType,dataRows){
    	var _this=this;
    	global.ajaxLoading.pop('正在拼命加载,请稍候!',true);
    	var getTimestamp=new Date().getTime();
		$('#detailNightDrivingPop').modal('show');
		var params = {
                dataType : 'json',
                url : appCtx+"/report/vehicleRunning/getVehicleAlarmDetails.html?v="+getTimestamp,
                method: 'GET',
                params:[
                	{
                		alarmType : alarmType,
                		starDateTime : _this.curQueryStartTime,
                		endDateTime:_this.curQueryEndTime,
                		vehicleId:dataRows.vehicleId
                	}
                ],
                dataType : 'json',
                colModel :convoyRunning.getNightDrivingColumn(),
                resizable : false,
                usepager:false,          
                width : 'auto',// 表格宽度
                height : 330, // 表格高度
                //widthType:'%',
	            width:$('.detail-report').width(),
	            rp : 100000,
                autoload: true,
                sortname:'registrationNO',
                onSuccess : function(data){
                	global.ajaxLoading.close();
                },
                onSelectRow : function(row){
                               
                },
                onSelectAllRow : function(data){

                },
                onChangeSort : function(data){
                	console.log(data);
                }
            }
		if($("#detailNightDrivingTable").html() == ''){
			$("#detailNightDrivingTable").flexigrid(params);
		}else{
			$("#detailNightDrivingTable").flexOptions({
				params:[
                	{
                		alarmType : alarmType,
                		starDateTime : _this.curQueryStartTime,
                		endDateTime:_this.curQueryEndTime,
                		vehicleId:dataRows.vehicleId
                	}
                ],
                colModel:convoyRunning.getNightDrivingColumn()
			});
			$("#detailNightDrivingTable").flexReload();
		
		}
		
	
    },
	
	popRoadOverspeedModel : function(alarmType,dataRows){
		var _this=this;
		global.ajaxLoading.pop('正在拼命加载,请稍候!',true);
	$('#detailRoadOverspeedPop').modal('show');	
	var getTimestamp=new Date().getTime();
	var params = {
            dataType : 'json',
            url : appCtx+"/report/vehicleRunning/getVehicleAlarmDetails.html?v="+getTimestamp,
            method: 'GET',
            params:[
            	{
            		alarmType : alarmType,
            		starDateTime : _this.curQueryStartTime,
            		endDateTime:_this.curQueryEndTime,
            		vehicleId:dataRows.vehicleId
            	}
            ],
            dataType : 'json',
            colModel :convoyRunning.getRoadOverspeedColumn(),
            resizable : false,
            usepager:false,          
            width : 'auto',// 表格宽度
            height : 340, // 表格高度
            //widthType:'%',
            width:$('.detail-report').width(),
            rp : 100000,
            autoload: true,
            sortname:'registrationNO',
            onSuccess : function(data){
            	global.ajaxLoading.close();
            },
            onSelectRow : function(row){
                           
            },
            onSelectAllRow : function(data){

            },
            onChangeSort : function(data){
            	//console.log(data);
            }
        }
	if($("#detailRoadOverspeedTable").html() == ''){
		$("#detailRoadOverspeedTable").flexigrid(params);
	}else{
		$("#detailRoadOverspeedTable").flexOptions({
			params:[
            	{
            		alarmType : alarmType,
            		starDateTime : _this.curQueryStartTime,
            		endDateTime:_this.curQueryEndTime,
            		vehicleId:dataRows.vehicleId
            	}
            ],
            colModel:convoyRunning.getRoadOverspeedColumn()
		});
		$("#detailRoadOverspeedTable").flexReload();
	
	}
	

	},
	popVehicleSpeedModel : function(alarmType,dataRows){
		var _this=this;
		global.ajaxLoading.pop('正在拼命加载,请稍候!',true);
		var getTimestamp=new Date().getTime();
	$('#detailVehicleSpeedPop').modal('show');
	var vehicleId=dataRows.vehicleId;
	var params = {
            dataType : 'json',
            url : appCtx+"/report/vehicleRunning/getVehicleAlarmDetails.html?v="+getTimestamp,
            method: 'GET',
            params:[
            	{
            		alarmType : alarmType,
            		starDateTime : _this.curQueryStartTime,
            		endDateTime:_this.curQueryEndTime,
            		vehicleId:vehicleId
            	}
            ],
            dataType : 'json',
            colModel :convoyRunning.getVehicleSpeedColumn(),
            resizable : false,
            usepager:false,          
            width : 'auto',// 表格宽度
            height : 330, // 表格高度
            //widthType:'%',
            width:$('.detail-report').width(),
            rp : 100000,
            autoload: true,
            sortname:'registrationNO',
            onSuccess : function(data){
            	global.ajaxLoading.close();
            },
            onSelectRow : function(row){
                           
            },
            onSelectAllRow : function(data){

            },
            onChangeSort : function(data){
            	//console.log(data);
            }
        }
	if($("#detailVehicleSpeedTable").html() == ''){
		$("#detailVehicleSpeedTable").flexigrid(params);
	}else{
		$("#detailVehicleSpeedTable").flexOptions({
			params:[
            	{
            		alarmType : alarmType,
            		starDateTime : _this.curQueryStartTime,
            		endDateTime:_this.curQueryEndTime,
            		vehicleId:vehicleId
            	}
            ],
            colModel:convoyRunning.getVehicleSpeedColumn()
		});
		$("#detailVehicleSpeedTable").flexReload();
	
	}
	

	},
	popVehiclePicModel : function(alarmType,dataRows){
		var _this=this;
		global.ajaxLoading.pop('正在拼命加载,请稍候!',true);
		var getTimestamp=new Date().getTime();
		$('#detailVehiclePicop').modal('show');
		var params = {
	            dataType : 'json',
	            url : appCtx+"/report/vehicleRunning/getVehicleAlarmDetails.html?v="+getTimestamp,
	            method: 'GET',
	            params:[
	            	{
	            		alarmType : alarmType,
	            		starDateTime : _this.curQueryStartTime,
	            		endDateTime:_this.curQueryEndTime,
	            		vehicleId:dataRows.vehicleId
	            	}
	            ],
	            dataType : 'json',
	            colModel :convoyRunning.getVehiclePicColumn(),
	            resizable : false,
	            usepager:false,          
	            width : 'auto',// 表格宽度
	            height : 330, // 表格高度
	            //widthType:'%',
	            width:$('.detail-report').width(),
	            rp : 100000,
	            autoload: true,
	            sortname:'registrationNO',
	            onSuccess : function(data){
	            	global.ajaxLoading.close();
	            },
	            onSelectRow : function(row){
	                           
	            },
	            onSelectAllRow : function(data){

	            },
	            onChangeSort : function(data){
	            	//console.log(data);
	            }
	        }
		if($("#detailVehiclePicTable").html() == ''){
			$("#detailVehiclePicTable").flexigrid(params);
		}else{
			$("#detailVehiclePicTable").flexOptions({
				params:[
	            	{
	            		alarmType : alarmType,
	            		starDateTime : _this.curQueryStartTime,
	            		endDateTime:_this.curQueryEndTime,
	            		vehicleId:dataRows.vehicleId
	            	}
	            ],
	            colModel:convoyRunning.getVehiclePicColumn()
			});
			$("#detailVehiclePicTable").flexReload();
		
		}
		

		},
	popVehicleTiredModel : function(alarmType,dataRows){
		var _this=this;
		global.ajaxLoading.pop('正在拼命加载,请稍候!',true);
		var getTimestamp=new Date().getTime();
	$('#detailVehicleTiredPop').modal('show');
	var params = {
            dataType : 'json',
            url : appCtx+"/report/vehicleRunning/getVehicleAlarmDetails.html?v="+getTimestamp,
            method: 'GET',
            params:[
            	{
            		alarmType : alarmType,
            		starDateTime : _this.curQueryStartTime,
            		endDateTime:_this.curQueryEndTime,
            		vehicleId:dataRows.vehicleId
            	}
            ],
            dataType : 'json',
            colModel :convoyRunning.getVehicleTiredColumn(),
            resizable : false,
            usepager:false,          
            width : 'auto',// 表格宽度
            height :330, // 表格高度
            //widthType:'%',
            width:$('.detail-report').width(),
            rp : 100000,
            autoload: true,
            sortname:'registrationNO',
            onSuccess : function(data){
            	global.ajaxLoading.close();
            },
            onSelectRow : function(row){
                           
            },
            onSelectAllRow : function(data){

            },
            onChangeSort : function(data){
            	//console.log(data);
            }
        }
	if($("#detailVehicleTiredTable").html() == ''){
		$("#detailVehicleTiredTable").flexigrid(params);
	}else{
		$("#detailVehicleTiredTable").flexOptions({
			params:[
            	{
            		alarmType : alarmType,
            		starDateTime : _this.curQueryStartTime,
            		endDateTime:_this.curQueryEndTime,
            		vehicleId:dataRows.vehicleId
            	}
            ],
            colModel:convoyRunning.getVehicleTiredColumn()
		});
		$("#detailVehicleTiredTable").flexReload();
	
	}
	

	},
    bind:function(){
    	var _this=this;
    	$("#selConvoyRuning").click(function(){
    		_this.queryConvoyRuning();
    	});
    },
    doSelTime:function(){
      var startTime=$("#inputStartDate").val();
      var endTime=$("#inputEndDate").val();
      
      if((startTime==null||startTime=="")&&(endTime==null||endTime=="")){
      	var todayDate = new Date();
      	todayDate = new Date(todayDate-86400000);
      	var todayDateStr=todayDate.getFullYear()+"-"+(todayDate.getMonth()+1)+"-"+todayDate.getDate();  
      	$("#inputEndDate").val(todayDateStr);
      	
      	var beforeDate = new Date(todayDate-86400000*3); //当前时间向前推7天
        var yyyy = beforeDate.getFullYear(), mm = (beforeDate.getMonth() + 1).toString(), dd = beforeDate.getDate().toString();
        if (mm.length == 1) {
             mm = '0' + mm;
        }
        if (dd.length == 1) {
             dd = '0' + dd;
        }
      	$("#inputStartDate").val(todayDateStr)
      }
    },
    getColumn:function(){
      return [{
            display : '车牌',
            name : 'registrationNO',
            width : 10,
            sortable : true,
            align : 'left',
            className:'cursor',
            paramcolnames:['vehicleId','registrationNO'],
            handlefunction:convoyRunning.formatAction
        },{
	        display : '车辆id',
	        name : 'vehicleId',
	        width : 0,
	        sortable : true,
	        align : 'left',
	        hide:true
    	},{
            display : '自编号',
            name : 'internalNumber',
            width : 10,
            sortable : true,
            align : 'left',
        },{
            display : '总里程',
            name : 'totalMileage',
            width : 10,
            sortable : true,
            align : 'left',
            paramcolnames:['totalMileage'],
            handlefunction:convoyRunning.doMileageFormat
        },{
            display : '行驶时长',
            name : 'duration',
            width : 10,
            sortable : true,
            align : 'left',
            paramcolnames:['duration'],
            handlefunction:convoyRunning.doTimeFormat
        },{
            display : '图片',
            name : 'picCount',
            width : 10,
            className:'cursor',
            
            align : 'left',
            sortable:true,
            paramcolnames:['picCount'],
            handlefunction:convoyRunning.changeColor
        },{
        	 display : '道路超速',
             name : 'totalRoadOverspeed',
             width : 10,
             className:'cursor',
             
             align : 'left',
             sortable:true,
             paramcolnames:['totalRoadOverspeed'],
             handlefunction:convoyRunning.changeColor
        },{
        	display : '夜间行车',
            name : 'totalNightDriving',
            width : 15,
            className:'cursor',
            
            align : 'left',
            sortable:true,
            paramcolnames:['totalNightDriving'],
            handlefunction:convoyRunning.changeColor
        },{
        	display : '车辆超速',
            name : 'totalVehicleSpeed',
            width : 10,
            className:'cursor',
            
            align : 'left',
            sortable:true,
            paramcolnames:['totalVehicleSpeed'],
            handlefunction:convoyRunning.changeColor
            
        },{
        	display : '疲劳驾驶',
            name : 'totalVehicleTired',
            width : 10,
            className:'cursor',
            
            align : 'left',
            sortable:true,
            paramcolnames:['totalVehicleTired'],
            handlefunction:convoyRunning.changeColor
           
        }];
    },
    formatAction:function(vehicleId,registrationNO){
		var str ="<a href='"+appCtx+"views/business/report/vehicleRunning.jsp?vid="+vehicleId+"' target='_Blank' style='color:blue;'>"+registrationNO+"</a>";
		return str;
    },
    loadDetailsTitle:function(){
    	$("#ObjTableDetails").flexigrid({
	            dataType : 'json',
	            colModel :this.getColumn(),
	            usepager : false,// 是否分页，默认为true。
	            height:330,
	            widthType:'%',
	            width:$('.detail-report').width(),
	            rp : 100000,
	            sortorder: 'desc',
	            sortable: true,
	            sortname:'registrationNO',
	            onSelectRow:function(rows,dataTitle){
	            	//console.log(rows,dataTitle);
	            	switch(dataTitle){
            		
            		case "totalVehicleSpeed":
            			convoyRunning.popVehicleSpeedModel(dataTitle,rows);
            			break;
            		case "totalVehicleTired":
            			convoyRunning.popVehicleTiredModel(dataTitle,rows);
            			break;
            		case "totalRoadOverspeed":
            			convoyRunning.popRoadOverspeedModel(dataTitle,rows);
            			break;
            		case "totalNightDriving":
            			convoyRunning.popNightDrivingModel(dataTitle,rows);
            			break;
            		case "picCount":
            			convoyRunning.popVehiclePicModel(dataTitle,rows);
            			break;
            	}
	            },
	            onChangeSort : function(data){
                	//console.log(data);
                }
	         });	 
    },
    exportExcel : function(){
		var header1 = JSON.stringify(convoyRunning.getColumn());
		var header2 = JSON.parse(header1);
		var headerWidth = $('.detail-report').width();
		for(var i=0;i<header2.length;i++){
			header2[i].width = Math.ceil(headerWidth / 100 * header2[i].width);
		}
		var header3 = JSON.stringify(header2);
		
		 var imageUrl = convoyRunning.behavior.chartDrivingDom.getDataURL({
			type: 'png',
		    pixelRatio: 1
		}); 
		 var imageUrl2 = convoyRunning.mileage.chartMillageDom.getDataURL({
				type: 'png',
			    pixelRatio: 1
		}); 
		//表头
		var colModelList=new Array();
		colModelList.push(header3);
		var colModel= $.toJSON(colModelList);
		
		//图片
		var imgsrcList=new Array();
		imgsrcList.push(imageUrl);
		imgsrcList.push(imageUrl2);
		var imgsrc= $.toJSON(imgsrcList);
		
		var totolTitle="";
		var totolInfo="";
		var sheetNameArr=['统计信息'];
		$("#objTitle th").each(function(index){
			//totolTitleArr.push($.trim($(this).text())+",");
			totolTitle+=$.trim($(this).text())+",";
		});
		$("#objInfo td").each(function(){
			totolInfo+=$.trim($(this).text())+",";
		});
		totolTitle=totolTitle.substring(0,totolTitle.length-1);
		totolInfo=totolInfo.substring(0,totolInfo.length-1);
		
		var param =  {
				startTime:$("#inputStartDate").val(),  
				endTime: $("#inputEndDate").val()+" 59:59:59",  
				workunitid:$("#selectVehicleUnitSel").val(),
				newSheetName:'统计信息',
				totolTitle:totolTitle,
				totolInfo:totolInfo,
				colModel:colModel,
				title:"车队行驶分析导出",
				imgsrc:imgsrc
		};
		post(appCtx+"report/convoyRunning/exportConvoyRunning.html",param);
		
	},
	bindExportExcel:function(){
		var _this=this;
    	$("#exportExcel").click(function(){
    		_this.exportExcel();
    	});
	},
	doLatLngFormat:function(latOrLng){ //处理经纬度格式
		return (latOrLng/1000000);
	},
	doMileageFormat:function(mileage){ //处理里程格式
		return (mileage)+"km";
	},
	doTimeFormatMin:function(time){
		return (time/60)+"分钟";
	},
	doTimeFormatTire:function(ms){ //处理时间格式
		var timeStr="";  
		if(ms ==""||ms ==null||ms =="null"||typeof(ms)=="undefined"){
			return timeStr;
		}
	/*	 var hour =Math.floor(ms/3600000);  
		 var minute =Math.floor((ms-hour*3600000)/60000);  
		 var second=ms-hour*3600000-minute*60000;
		 var second = Math.floor((ms-hour*3600000-minute*60000)/1000);  
		 var milliSecond=ms-hour*3600000-minute*60000-second*1000;*/
		 var hour =Math.floor(ms/3600);  
		 var minute =Math.floor((ms-hour*3600)/60);  
		 var second=Math.floor(ms-hour*3600-minute*60);
		
	      
		 timeStr=hour+"小时"+minute+"分";
	   
	    return timeStr;
	}
	,
	doTimeFormat:function(ms){ //处理时间格式
		var timeStr="";  
		if(ms ==""||ms ==null||ms =="null"||typeof(ms)=="undefined"){
			return timeStr;
		}
	/*	 var hour =Math.floor(ms/3600000);  
		 var minute =Math.floor((ms-hour*3600000)/60000);  
		 var second=ms-hour*3600000-minute*60000;
		 var second = Math.floor((ms-hour*3600000-minute*60000)/1000);  
		 var milliSecond=ms-hour*3600000-minute*60000-second*1000;*/
		 var hour =Math.floor(ms/3600);  
		 var minute =Math.floor((ms-hour*3600)/60);  
		 var second=Math.floor(ms-hour*3600-minute*60);
		
	      
		 timeStr=hour+"小时"+minute+"分"+second+"秒";
	   
	    return timeStr;
	},getAddressS:function (start_lon,start_lat,id){
		id=id.replace(/[^0-9]/ig,""); 
		showAddress("spans"+id,(start_lon/1000000),(start_lat/1000000));
		return '<div id="spans'+id+'"><a href="#" >加载中..</a></div>';
  },
	changeColor:function(value){ //改变字体颜色
		return "<span style='color:blue;'>"+value+"</span>"
	},getAddressE:function (start_lon,start_lat,id){
		id=id.replace(/[^0-9]/ig,""); 
		showAddress("spane"+id,(start_lon/1000000),(start_lat/1000000));
		return '<div id="spane'+id+'"><a href="#" >加载中..</a></div>';
}

};

convoyRunning.init();

function showAddress(id,start_lon,start_lat){
	var ctrl="#"+id;
	var geocoder = new AMap.Geocoder({
        radius: 1000,
        extensions: "all"
    });        
    geocoder.getAddress(new AMap.LngLat(start_lon,start_lat), function(status, result) {
        if (status === 'complete' && result.info === 'OK') {
        	var address=result.regeocode.formattedAddress;
        	$(ctrl).html(address);
        	$(ctrl).attr("title",address);
        }
    });    
}


